/*
 * @Author: Setsuna
 * @Email: setsuna.xyz@qq.com
 * @FilePath: \src\lib\types\form.ts
 * @Date: 2021-07-09 11:25:54
 * @LastEditTime: 2022-03-17 16:08:28
 */
import { InputProps } from 'antd/lib/input'
import { SelectProps } from 'antd/lib/select'
import { GetFieldDecoratorOptions, ValidationRule, WrappedFormUtils } from 'antd/lib/form/Form'
import { Validator } from '../utils/validators'
import { RangePickerProps } from 'antd/lib/date-picker/interface'
import { ColProps } from 'antd/lib/col'
import { ReactNode } from 'react'
import { AxiosPromise } from 'axios'

// export type IFormItem = IFormItemSelectAjax | IFormItemDateRangePicker | IFormItemCustom

/** Ud表单项 */
export interface IUdFormItem {
  /** 字段名 */
  id: string | string[]
  /** 显示名 */
  label?: React.ReactNode

  /**
   * 传入符合antd表单控件的组件
   * @default `<Input />`
   * @type React.ReactElement | ((item: IUdFormItem) => React.ReactElement)
   */
  render?: React.ReactElement | ((item: IUdFormItem) => React.ReactElement)

  /** 验证规则，validators类中内置一些常用的验证器 */
  rules?: (Validator | ValidationRule)[]
  /** 初始值 */
  initialValue?: any

  /** antd 表单配置  */
  decoratorOptions?: GetFieldDecoratorOptions

  colSpan?: ColProps

  labelCol?: ColProps

  wrapperCol?: ColProps

  extra?: React.ReactNode

  props?: any

  /** 此属性不用手动传 */
  value?: any
  /** 此属性不用手动传 */
  onChange?(value: any): void
  /** 此属性不用手动传 */
  form?: WrappedFormUtils
  className?: string
}

// export interface IFormItemCustom extends IFormItemDefine {
//   type?: 'Custom'
//   render: React.ReactNode
// }

// export interface IFormItemDateRangePicker extends IFormItemDefine {
//   /** 日期范围选择器 */
//   type: 'DateRangePicker'
//   props?: RangePickerProps
// }

// export interface IFormItemSelectAjax extends IFormItemDefine {

//   props?: SelectProps
// }

// export type Rule = ''
